//
//  HJCarDeailViewController.m
//  YaDiuDiu
//
//  Created by 胡光健 on 2017/10/29.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "HJCarDeailViewController.h"
#import "StarView.h"
@interface HJCarDeailViewController ()
@property (weak, nonatomic) IBOutlet UILabel *orderNo;
@property (weak, nonatomic) IBOutlet UILabel *orderTime;
@property (weak, nonatomic) IBOutlet UILabel *carType;
@property (weak, nonatomic) IBOutlet UILabel *phone;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet UIButton *pinjiaBtn;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *btmH;
@property (weak, nonatomic) IBOutlet UIView *star;
@property (weak, nonatomic) IBOutlet UILabel *comment;


@property(nonatomic,strong)StarView *starView;
@end

@implementation HJCarDeailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self showNav:@"订单详情"];
    [self loadData];
}
-(void)loadData {
    NSString * url = [NSString stringWithFormat:@"%@/App/Ordermanage/buycarorderdetails",urlHead];
    [TZHttpTool post:url params:@{@"id":self.merchantid,@"merchantid":self.meri_id} success:^(NSDictionary *result) {
        NSDictionary *dic = result[@"result"];
        dispatch_async(dispatch_get_main_queue(), ^{
            self.orderNo.text = dic[@"ordernumber"];
            self.orderTime.text = [TZHttpTool getNewDate:dic[@"addtime"]];
            self.carType.text = dic[@"ordername"];
            self.phone.text = dic[@"phone"];
        });
        NSDictionary * commentDic = result[@"result"][@"comment"];
        if (self.type==1) {
            self.pinjiaBtn.hidden = YES;
            self.bottomView.hidden = YES;
        }else {
            self.btmH.constant = 90.0;
            self.bottomView.hidden = NO;
            if ([commentDic[@"comment"] isEqualToString:@""]) {
                self.comment.text = @"暂无用户评论";
            }else {
                self.comment.text =commentDic[@"comment"];
            }
            self.starView = [[StarView alloc]init];
            self.starView.showStar = [commentDic[@"star"] integerValue]* 20;
            [self.star addSubview:self.starView];
            [self.star makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.equalTo(13);
                make.top.equalTo(self.starView.top);
                make.width.equalTo(80);
                make.height.equalTo(16);
            }];
        }
        
        
    } failure:^(NSString *msg) {
        [LICGToast showWithText:msg];
    }];
}
- (IBAction)tellBtn:(UIButton *)sender {
    
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",self.phone.text]]];
    
}

@end
